home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / Palm Finder 2 / Src / Panes / pane.cpp < prev    next >
Encoding:
Text File  |  2001-06-23  |  3.1 KB  |  230 lines

  1. // pane.cpp
  2.  
  3. #include "pane.h"
  4. #include "view.h"
  5.  
  6.  
  7. //
  8. // constructor
  9. //
  10. pane::pane(RectangleType* in_bounds, view* in_superview)
  11. {
  12.     RctCopyRectangle (in_bounds, &m_bounds);
  13.     m_superview = in_superview;    
  14.     m_visible = true;
  15.  
  16.     add_to_master_list();
  17. }
  18.  
  19. //
  20. // constructor
  21. //
  22. pane::pane(view* in_superview)
  23. {
  24.     m_bounds.topLeft.x = 0;
  25.     m_bounds.topLeft.y = 0;
  26.     m_bounds.extent.x = 0;
  27.     m_bounds.extent.y = 0;
  28.     m_superview = in_superview;
  29.     m_visible = true;
  30.  
  31.     add_to_master_list();
  32. }
  33.  
  34. //
  35. // default constructor
  36. //
  37. pane::pane()
  38. {
  39.     m_bounds.topLeft.x = 0;
  40.     m_bounds.topLeft.y = 0;
  41.     m_bounds.extent.x = 0;
  42.     m_bounds.extent.y = 0;
  43.     m_superview = NULL;
  44.     m_visible = true;
  45.     add_to_master_list();
  46. }
  47.  
  48. //
  49. // destructor
  50. //
  51. pane::~pane() {
  52.     if (m_next_pane!=NULL)
  53.         delete m_next_pane;
  54.     remove_from_master_list();
  55. }
  56.  
  57.  
  58. #pragma mark -
  59.  
  60. //
  61. // get_superview()
  62. //
  63. view*
  64. pane::get_superview() {
  65.     return m_superview;
  66. }
  67.  
  68.  
  69. //
  70. // draw()
  71. //
  72. void        
  73. pane::draw(){
  74.     if (m_next_pane!=NULL)
  75.         m_next_pane->draw();
  76.     if (m_visible)
  77.         draw_self();
  78. }
  79.  
  80. //
  81. // click()
  82. //
  83. Boolean    
  84. pane::click(int x, int y) {
  85.     Boolean handled = false;
  86.     
  87.     if ((not handled) && (m_next_pane!=NULL))
  88.         handled = m_next_pane->click (x, y);
  89.     if ((not handled) && RctPtInRectangle (x, y, &m_bounds) && m_visible)
  90.         handled = click_self(x, y);
  91.     
  92.     return handled;
  93. }
  94.  
  95. //
  96. // still_down()
  97. //
  98. Boolean    
  99. pane::still_down(int x, int y) {
  100.     Boolean handled = false;
  101.     
  102.     if (m_next_pane!=NULL)
  103.         handled = m_next_pane->still_down (x, y);
  104.     if (not handled  && m_visible)
  105.         handled = still_down_self(x, y);
  106.         
  107.     return handled;
  108. }
  109.  
  110. //
  111. // pen_up()
  112. //
  113. Boolean    
  114. pane::pen_up(int x, int y) {
  115.     Boolean handled = false;
  116.     
  117.     if (m_next_pane!=NULL)
  118.         handled = m_next_pane->pen_up (x, y);
  119.     if (not handled  && m_visible)
  120.         handled = pen_up_self(x, y);
  121.     
  122.     return handled;
  123. }
  124.  
  125. //
  126. // idle()
  127. //
  128. void
  129. pane::idle() {
  130.     if (m_next_pane!=NULL)
  131.         m_next_pane->idle();
  132.     idle_self();
  133. }
  134.  
  135. #pragma mark -
  136. #pragma mark  Protected:
  137.  
  138. //
  139. // draw_self()
  140. //
  141. void
  142. pane::draw_self() {
  143.     // do nothing
  144. }
  145.  
  146. //
  147. // click_self()
  148. //
  149. Boolean
  150. pane::click_self(int x, int y) {
  151.     #pragma unused (x, y)
  152.     // do nothing
  153.     return false;
  154. }
  155.  
  156. //
  157. // still_down_self()
  158. //
  159. Boolean
  160. pane::still_down_self(int x, int y) {
  161.     #pragma unused (x, y)
  162.     // do nothing
  163.     return false;
  164. }
  165.  
  166. //
  167. // pen_up_self()
  168. //
  169. Boolean
  170. pane::pen_up_self(int x, int y) {
  171.     #pragma unused (x, y)
  172.     // do nothing
  173.     return false;
  174. }
  175.  
  176. //
  177. // idle_self()
  178. //
  179. void
  180. pane::idle_self() {
  181.     // do nothing
  182. }
  183.  
  184. #pragma mark -
  185. #pragma mark  Private:
  186.  
  187. //
  188. // add_to_master_list()
  189. //
  190. void 
  191. pane::add_to_master_list() {
  192.     this->m_next_pane = NULL;
  193.     if (m_superview==NULL) return;
  194.     
  195.     pane* p = m_superview->get_subpanes();
  196.     
  197.     if (p==NULL) {
  198.         m_superview->set_subpanes(this);
  199.     } else {
  200.         while (p->m_next_pane != NULL) {
  201.             p = p->m_next_pane;
  202.         }
  203.         p->m_next_pane = this;
  204.     }
  205. }
  206.  
  207. //
  208. // remove_from_master_list()
  209. //
  210. void    
  211. pane::remove_from_master_list() {
  212.     if (m_superview==NULL) return;
  213.  
  214.     pane* p = m_superview->get_subpanes();
  215.     pane* next = this->m_next_pane;
  216.     
  217.     this->m_next_pane = NULL;
  218.     if (p==this) {
  219.         m_superview->set_subpanes(next);
  220.     } else {
  221.         while (p!=NULL) {
  222.             if (p->m_next_pane == this) {
  223.                 p->m_next_pane = next;
  224.                 break;
  225.             }
  226.             p = p->m_next_pane;
  227.         }
  228.     }
  229. }
  230.